<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="directive.jsp" />
<jsp:include page="header.jsp" />

    <div id="inner_wrap">
	<div id="inner_hold">
	<div id="inner">
	<div class="center_hold">
		<div id="shop_top_menu">
			<ul class="jsddm">
                <!-- category loop here -->
                <c:forEach items="${category.categoryList}" var="item">
                    <li class="non_drop_page"><a href="index.jsp?cat=${item.categoryID}">${item.categoryName}</a></li>
                </c:forEach>
			</ul>
			<div class="empty"></div>
		</div>
                
        <c:set var="query" value="${param.q}"/>
        <c:if test="${empty query}">
            <jsp:forward page="index.jsp"/>
        </c:if>
            <jsp:setProperty name="product" property="searchQuery" value="${query}"/>
        <div id="shop_h_one">
			<h1>Search result for: "${query}"</h1>
		</div>
                
                <c:set var="page" value="${param.page}"/>
                <c:if test="${empty page}">
                    <c:set var="page" value="1"/>
                </c:if>
                <!-- loop of products -->
                <c:forEach items="${product.searchResultList}" var="item" varStatus="status">
                    <c:if test="${status.count <= page*10 && status.count > (page - 1)*10}">
                    <div class="four_clmn">
                        <a href="product.jsp?id=${item.productID}">
                            <img src="product_img/${item.productID}.jpg" width="130" height="158" alt="${item.productName}" title="${item.productName}" class="thumby" />
                        </a>
                        <c:if test="${page == 1 && status.count < 5}">
                            <div class="new_s"></div>
                        </c:if>
                        <div class="title_pro"><a href="product.jsp?id=${item.productID}" class="blue">${item.productName}</a></div>
                        <p class="four_price"><span>${item.unitPrice}</span></p>
                    </div>
                    </c:if>
                </c:forEach>
		
        <!-- pages -->
		<div class="empty"></div>
		<div class="pagin">
			<span class="pagin_in">
                <c:forEach var="item" begin="1" end="${product.searchResultPages}" step="1">
                    <a href="search.jsp?q=${query}&page=${item}" class="active">${item}</a>
                </c:forEach>
			</span>
		</div>
	</div>
	</div>
	</div>
	</div>

<jsp:include page="footer.jsp" />